package com.zky.common.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @Description 日期工具类
 * @Author 张开源
 * @Date 2022/12/24 3:02
 * @Version 1.0
 **/
public class DateUtil {

    public static final String NORMAL_FORMAT = "yyyy-MM-dd HH:mm:ss";

    public static String getDateString(Date date) {
        try {
            SimpleDateFormat df = new SimpleDateFormat(NORMAL_FORMAT);
            String dateString = df.format(date);
            System.out.println(dateString);
            return dateString;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    public static Date getDate(String date) {
        try {
            SimpleDateFormat df = new SimpleDateFormat(NORMAL_FORMAT);
            Date parse = df.parse(date);
            System.out.println(parse);
            return parse;
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return null;
    }
}
